package org.example.lanchain.mapper;

import org.apache.ibatis.annotations.*;
import org.example.lanchain.bean.AiAssistantStats;

@Mapper
public interface AiAssistantStatsMapper {
    @Select("SELECT * FROM ai_assistant_stats WHERE user_id = #{userId} LIMIT 1")
    AiAssistantStats getStatsByUserId(@Param("userId") Long userId);

    @Insert("INSERT INTO ai_assistant_stats (user_id, total_users, total_messages, avg_response_time, satisfaction_rate, total_assistants, update_time) VALUES (#{userId}, #{totalUsers}, #{totalMessages}, #{avgResponseTime}, #{satisfactionRate}, #{totalAssistants}, #{updateTime})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void insertStats(AiAssistantStats stats);

    @Update("UPDATE ai_assistant_stats SET total_users=#{totalUsers}, total_messages=#{totalMessages}, avg_response_time=#{avgResponseTime}, satisfaction_rate=#{satisfactionRate}, total_assistants=#{totalAssistants}, update_time=#{updateTime} WHERE user_id=#{userId}")
    void updateStats(AiAssistantStats stats);
} 